<template>
  <div class="contain">
    <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="onLoad"
      >
        <div v-for="(item,index) in list" :key="index">
            <van-cell  :title="item.name" />
        </div>
      </van-list>
    </van-pull-refresh>
  </div>
</template>
<script>
import helper from "../../service/helper.js";
import parameter from "../../service/state.js";
export default {
  data() {
    return {
      list: [],
      pushList: {name:'添加数据'},
      loading: false,
      finished: false,
      refreshing: false,
      total:20,
      pageNo:0,
      pageSize:10,
    };
  },
  components: {},
  methods: {
      onLoad() {
                 //接口报错设置
    //     fetchSomeThing().catch(() => {
    //     this.error = true;
    //   });
      setTimeout(() => {
        if (this.refreshing) {
          this.list = []
          this.refreshing = false;
        }
        for (let i = 0; i < this.pageSize; i++) {
          this.list.push(this.pushList);
        }
        this.loading = false;

        if (this.list.length >= this.total) {
          this.finished = true;
        }
      }, 1000);
    },
    onRefresh() {
      // 清空列表数据
      this.finished = false;
      // 重新加载数据
      // 将 loading 设置为 true，表示处于加载状态
      this.loading = true;
      this.onLoad();
    },
  },
  watch: {},
  mounted() {},
};
</script>
<style scoped>
</style>